from CONN import conn
#获取游标
cursor = conn.cursor()
#捕获操作数据库的异常
try:
    cursor.execute("update student set name='张三' where id=4")
    # 检查更新影响的行数
    affected_rows = cursor.rowcount
    print(f"更新了 {affected_rows} 行数据")
except Exception as e:
    print("更新数据失败:", e)
finally:
    # 关闭游标和连接是个好习惯
    cursor.close()
    conn.close() 
#更新了 1行